package com.shirley.customcontrols;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.shirley.android.selectitem.ItemBean;
import com.shirley.android.selectitem.SelectItemView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 主界面的Tab4对应的fragment
 * Created by ZLJ on 2017/12/18.
 */
public class Fragment4 extends Fragment {

    @BindView(R.id.select_item)
    SelectItemView selectItem;
    @BindView(R.id.select_item_multi)
    SelectItemView selectItemMulti;
    Unbinder unbinder;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment4, container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        selectItem.setData(initData3());
        selectItemMulti.setData(initData3());
    }

    public List<ItemBean> initData3() {
        List<ItemBean> list = new ArrayList<>();

        ItemBean bean1 = new ItemBean();
        bean1.setText("选项1");
        list.add(bean1);

        ItemBean bean2 = new ItemBean();
        bean2.setText("选项2");
        list.add(bean2);

        ItemBean bean3 = new ItemBean();
        bean3.setText("选项3");
        list.add(bean3);

        ItemBean bean4 = new ItemBean();
        bean4.setText("选项4");
        list.add(bean4);

        return list;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
